package com.kyivmohyla.kma2.dao.mapper;

import com.kyivmohyla.kma2.model.Service;
import org.springframework.jdbc.core.ResultSetExtractor;

import java.sql.ResultSet;
import java.sql.SQLException;

class ServiceResultSetExtractor implements ResultSetExtractor<Service> {

    @Override
    public Service extractData(ResultSet resultSet) throws SQLException {
        Service service = new Service();
        try {
            service.setServiceId(resultSet.getInt("service_id"));
            service.setName(resultSet.getString("name"));
            service.setIsParent(resultSet.getInt("is_parent"));
            service.setParentId(resultSet.getInt("parent_id"));
            service.setDescription(resultSet.getString("description"));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return service;
    }

}